package com.lg.erp.controller.zhangchaofu;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lg.erp.entity.JsonResult;
import com.lg.erp.entity.zhangchaofu.TShipping;
import com.lg.erp.entity.zhangchaofu.ZCFTLogistics;
import com.lg.erp.entity.zhangchaofu.ZCFTOrder;
import com.lg.erp.service.zhangchaofu.TShippingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
public class TShippingController {

    @Autowired
    private TShippingService tShippingService;

    /**
     * 查询订单表里未发货的
     * @param current
     * @return
     */
    @ResponseBody
    @RequestMapping("/shipping-order/{current}")
    public JsonResult notShippingPage(@PathVariable Integer current){
        Page<ZCFTOrder> page=new Page<>(current,10);
        IPage<ZCFTOrder> pages =tShippingService.notShippingPage(page);
        return new JsonResult(1,"ok",pages);
    }


    /**
     * 查询全部的物流公司
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/shipping-company/{logisticsId}",method = RequestMethod.GET)
    public JsonResult findLogisticsCompany(@PathVariable("logisticsId") String logisticsId){
        List<ZCFTLogistics> ZCFTLogisticsList =tShippingService.findLogisticsCompany(logisticsId);
        return new JsonResult(1,"ok", ZCFTLogisticsList);
    }

    /**
     * 新增发货物流表
     * @param shipping
     * @return
     */
    @ResponseBody
    @PostMapping("/shipping")
    public JsonResult addSipping(@RequestBody TShipping shipping){
        tShippingService.addSipping(shipping);
        return new JsonResult(1,"ok", null);
    }

    /**
     * 查找订单发货单号等信息
     * @param orderId
     * @return
     */
    @GetMapping("/shipping/{orderId}")
    public JsonResult findShipping(@PathVariable String orderId){
        TShipping tShipping = tShippingService.findShipping(orderId);
        return new JsonResult(1,"ok",tShipping);
    }
}
